<template>
    <div>
        <Breadcrumb :style="{margin: '20px 0'}">
            <BreadcrumbItem>发布操作</BreadcrumbItem>
            <BreadcrumbItem>内容编辑</BreadcrumbItem>
        </Breadcrumb>
        <ButtonGroup class="button">
            <Button type="primary" @click="reload">刷新</Button>
            <Button type="primary" @click="createContent">添加</Button>
        </ButtonGroup>
        <Table :columns="columns" :data="contentList"></Table>
        <div>
            <Page :page-size="page.limit" :total="page.total" simple @on-change="pageChange"/>
        </div>
    </div>
</template>

<script>
import model from '../util/model'

export default {
    name: 'Content',
    data : function () {
        return {
            contentList : [],
            page: {
                limit: 10,
                skip: 0,
                total: 0
            },
            columns : [
                {
                    title: '标题',
                    key : 'title'
                },
                {
                    title : '关键字',
                    key : 'keyword'
                },
                {
                    title : '内容',
                    key : 'content'
                },
                {
                    title: '操作',
                    render: (h, p) => {
                        return h('div', [
                            h('Icon', {
                                props: {
                                    type: 'md-create',
                                    size: '14'
                                },
                                on: {
                                    'click': () => {
                                        this.editContent(p)
                                    }
                                }
                            }),
                            h('Icon', {
                                props: {
                                    type: 'md-trash',
                                    size: '14'
                                },
                                on: {
                                    'click': () => {
                                        this.removeOne(p)
                                    }
                                }
                            })

                        ])
                    }
                }

            ]
        }
    },
    created : function(){

    },
    methods : {
        reload: function(){

        },
        createContent : function () {
            this.$router.push('/ContentEdit')
        },
        pageChange: function (page) {
            this.page.skip = this.page.limit * page - this.page.limit
            this.getInfo()
        },

    }
}
</script>

<style scoped>

</style>
